﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="hrExaminationItemType.aspx.cs" Inherits="ZX.WebApp.EHR.hrExaminationItemType" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新增考核项目分类</title>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
    <link href="../Styles/extendTable.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
    // <![CDATA[

            $(document).ready(function () {
                parent.document.getElementById("dialog1_h").innerHTML = "新增考核项目分类";
                GetRootExaminationItemType();
            });

            function GetRootExaminationItemType() {
                var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_ExaminationItemType&condition=ClassID='00000000-0000-0000-0000-000000000000'";
                $.get(url, function (d, s) {
                    var list = eval("(" + d + ")");
                    var PhraseID = list.rows[0].PhraseID;
                    if (typeof (PhraseID) != "undefined") {
                        $("#ClassID").val(PhraseID);
                    }
                });
            }

    // ]]> 
     </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="tableContent" id="dutyTypeTable">
            <tr>
                <td style="height:30px; width:60px;">&nbsp;名称</td>
                <td>
                    <input type="hidden" id="ClassID" name="ClassID"  />
                    <input type="text" id="PhraseText" name="PhraseText" maxlength="50"/>
                    <span style="color: Red">*</span>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
<script type="text/javascript">
    var Entity = "ExaminationItemType";
    var Url = "";
    var instance = [{ "PhraseText": "", "ClassID": ""}];
    function Save() {
        var vName = document.getElementById("PhraseText").value;
        if (vName == "" || vName == null) {
            alert("名称不能为空!");
            document.getElementById("PhraseText").focus();
            return;
        } else {
            $("#dutyTypeTable").SetFormValueToObject(instance[0]);
            var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
            Url = "hrExaminationAjax.aspx?flag=SaveExaminationItemType" + "&json=" + encodeURI(json);
            SaveData();
        }
    }
    function SaveData(){
        YAHOO.util.Connect.asyncRequest('POST', Url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    if (inventory == 1) {
                        alert("保存成功!");
                        RefreshTreeData();
                        parent.closeWin();
                    } else {
                        alert(inventory);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }

    //保存后回调，刷新树
    function RefreshTreeData() {
        var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_ExaminationItemType&condition=PhraseText='" + instance[0].PhraseText + "'";
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            var PhraseID = list.rows[0].PhraseID;
            if (typeof (PhraseID) != "undefined") {
                parent.RefreshTreeData(instance[0].PhraseText, PhraseID);
            }
        });
    }
</script>
</html>
